From: Daiki Ueno Date: Mon, 13 Sep 2010 10:44:07 +0000 (+0900) Subject: epa-file: suppress file-locking question on M-x revert-buffer X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1^2~5^2~844^2~4062^2~25 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=c5fe4acb5fb456d6e8e147d8bc7981ce56c5c03d;p=emacs.git epa-file: suppress file-locking question on M-x revert-buffer * epa-file.el (epa-file-insert-file-contents): If visiting, bind buffer-file-name to avoid file-locking. (Bug#7026) --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index dec338e36d6..f0e59a6c6a6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2010-09-13 Daiki Ueno + + * epa-file.el (epa-file-insert-file-contents): If visiting, bind + buffer-file-name to avoid file-locking. (Bug#7026) + 2010-09-13 Julien Danjou * notifications.el (notifications-notify): Add support for diff --git a/lisp/epa-file.el b/lisp/epa-file.el index 24480ce3c76..3c6cf07ea1b 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -158,12 +158,17 @@ way." (if (or beg end) (setq string (substring string (or beg 0) end))) (save-excursion - (save-restriction - (narrow-to-region (point) (point)) - (epa-file-decode-and-insert string file visit beg end replace) - (setq length (- (point-max) (point-min)))) - (if replace - (delete-region (point) (point-max))) + ;; If visiting, bind off buffer-file-name so that + ;; file-locking will not ask whether we should + ;; really edit the buffer. + (let ((buffer-file-name + (if visit nil buffer-file-name))) + (save-restriction + (narrow-to-region (point) (point)) + (epa-file-decode-and-insert string file visit beg end replace) + (setq length (- (point-max) (point-min)))) + (if replace + (delete-region (point) (point-max)))) (if visit (set-visited-file-modtime)))) (if (and local-copy